<?php

/*
=====================================================
 Generic Toolbox - by Carl Wells
-----------------------------------------------------
-----------------------------------------------------
 Copyright (c) 2009 Carl Wells
=====================================================
 THIS IS COPYRIGHTED SOFTWARE
 PLEASE READ THE LICENSE AGREEMENT
=====================================================
 File: system/core/main.class.php
-----------------------------------------------------
 Purpose: This file powers all the other classes.
 It takes a $_GET variable 'act' (for action) then 
 determines what action to take.
 example:	section -> shows the sections
 			addpromos -> page where you can add a promo
 It also creates various objects depending on the requirements.
=====================================================
*/

class Main
{

	var $action;

	// CONTRUCTOR although not really, __construct is a constructor
	function Main(){
	
	}
        
	function getAction(){
		if ($_GET['act']){
    		$this->action = $_GET['act'];
    	}else{
    		$this->action = NULL;
    	}
    	$displayController = $this->displayContentProvider($this->action);
    	return $displayController;
    }
    
    // Decide what Main Content to create
  	// Will go through various classes
	function displayContentProvider($action){
	require_once ("display/navdisplay.class.php");
	$NAVDISPLAY = new Navdisplay();
	switch ($action) {
//	SELECT AND DISPLAY THE SECTOR	
	case "sections":
		require_once ("display/sectordisplay.class.php");
        $displayController = new Sectordisplay();
        $displayController->displaySectors();
        break;
//	SELECT AND DISPLAY EDIT SECTOR DISPLAY
	case "sectoredit":
		require_once ("display/sectordisplay.class.php");
        $displayController = new Sectordisplay();
        $displayController->displayEditSector($_GET['id']);
        break;
//	SELECT AND DISPLAY THE ADD SECTOR DISPLAY	
	case "addsector":
		require_once ("display/sectordisplay.class.php");
        $displayController = new Sectordisplay();
        $displayController->addSector();
        break;
//	SELECT AND DISPLAY THE PROMO SECTON
    case "promos":
        require_once ("display/adminpromodisplay.class.php");
        require_once ("display/admincategorydisplay.class.php");
       $displayController = new Categorydisplay();
        $NAVDISPLAY->displayPromosNav();
        $displayController->displayCurrentCategories();
        return $displayController;
        break;
//	SELECT AND DISPLAY THE CURRENT PROMOS SECTON
    case "displaycurrentpromotions":
        require_once ("display/adminpromodisplay.class.php");
        $displayController = new Adminpromodisplay();
        $NAVDISPLAY->displayPromosNav();
        $displayController->displayCurrentPromotions();
        return $displayController;
        break;
//	SELECT AND DISPLAY THE ADD SECTOR DISPLAY	
	case "addcategory":
		require_once ("display/admincategorydisplay.class.php");
        $displayController = new Categorydisplay();
        $displayController->addCategory($_GET['sector']);
        break;
//	SELECT AND DISPLAY THE CURRENT CATEGORIES SECTON
    case "displaycurrentcategories":
        require_once ("display/admincategorydisplay.class.php");
        $displayController = new Categorydisplay();
        $NAVDISPLAY->displayPromosNav();
        $displayController->displayCurrentCategories();
        return $displayController;
        break;
//	SELECT AND DISPLAY EDIT SECTOR DISPLAY
	case "categoryedit":
		require_once ("display/admincategorydisplay.class.php");
        $displayController = new Categorydisplay();
        $displayController->displayEditCategory($_GET['sectorId'], $_GET['id']);
        break;
        
        // Select Case and delete the promotion
        case "deletepromo":
        	require_once ("display/adminpromodisplay.class.php");
        	$displayController = new Adminpromodisplay;
        	$displayController->deleteSinglePromotion($_GET['promoid']);
        break;
        
//	SELECT AND DISPLAY THE ADDPROMO SECTON
    	case "addpromotion":
        require_once ("display/adminpromodisplay.class.php");
        $NAVDISPLAY->displayPromosNav();
        $displayController = new Adminpromodisplay();
        $displayController->addpromotion();
        return $displayController;
        break;
        
//	SELECT AND DISPLAY THE EDIT PROMO SECTON
    	case "editpromotions":
        require_once ("display/adminpromodisplay.class.php");
        $NAVDISPLAY->displayPromosNav();
        $displayController = new Adminpromodisplay();
        $displayController->displayAllPromotions();
        return $displayController;
        break;
      
//	SELECT AND DISPLAY SINGLE EDIT PROMO SECTON
    	case "editpromo":
        require_once ("display/adminpromodisplay.class.php");
        $NAVDISPLAY->displayPromosNav();
        $displayController = new Adminpromodisplay();
        $displayController->editSinglePromotion();
        return $displayController;
        break;
        
//	SELECT AND DISPLAY THE POS SECTON
    	case "pos":
        require_once ("display/adminposdisplay.class.php");
       // $NAVDISPLAY->displayPromosNav();
        $displayController = new Adminposdisplay();
        $displayController->displayPosFrontPage();
        return $displayController;
        break;

//	SELECT AND DISPLAY THE ADD POS SECTON
    	case "addpos":
        require_once ("display/adminposdisplay.class.php");
       // $NAVDISPLAY->displayPromosNav();
        $displayController = new Adminposdisplay();
        $displayController->displayAddPosFrontPage();
        return $displayController;
        break;
     
//	SELECT AND DISPLAY THE POS SECTON
    	case "displaycurrentpos":
        require_once ("display/adminposdisplay.class.php");
        $NAVDISPLAY->displayPromosNav();
        $displayController = new Adminposdisplay();
        $displayController->displayCurrentPos();
        return $displayController;
        break;
    
//	SELECT AND DISPLAY THE USER SECTON
    case "users":
        require_once ("display/userdisplay.class.php");
        $displayController = new Userdisplay();
        return $displayController;
        break;
        //   DEFAULT BEHAVIOUR
     default:
     break;
	}
	return $displayController;
	}
}

?>